package com.offics.frame.infrastructure.exception;

import lombok.Getter;

/**
 * 业务异常类
 * 用于封装业务逻辑异常
 */
@Getter
public class BusinessException extends RuntimeException {

    private final Integer code;

    private final String message;

    /**
     * 构造函数
     * @param code 错误码
     * @param message 错误消息
     */
    public BusinessException(Integer code,String message){
        super(message);
        this.code = code;
        this.message = message;
    }
    /**
     * 构造函数
     * @param code 错误码
     * @param message 错误消息
     * @param cause 原始异常
     */
    public BusinessException(Integer code,String message,Throwable cause){
        super(message, cause);
        this.code = code;
        this.message = message;
    }
    /**
     * 使用默认错误码构造异常
     * @param message 错误消息
     */
    public BusinessException(String message){
        this(400,message);
    }

}
